package com.papercut.gui;

import com.papercut.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class DashBoard extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
		LinearLayout dash_board_view = new LinearLayout(this);
		dash_board_view.setOrientation(LinearLayout.VERTICAL);
		dash_board_view.setBackgroundResource(R.drawable.dashboard_background);

		
		TextView app_title = new TextView(this);
		LinearLayout.LayoutParams app_title_layout = new LinearLayout.LayoutParams(
					LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		
		app_title_layout.setMargins(0, 20, 0, 0);
		app_title.setText("Dash Board");
		app_title.setTextSize(24);
		app_title.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
		app_title.setTextColor(Color.rgb(231, 122, 0));
		app_title.setGravity(Gravity.CENTER_HORIZONTAL);
		dash_board_view.addView(app_title, app_title_layout);
		
		ImageView notifications_button = new ImageView(this);
		LinearLayout.LayoutParams notifications_button_layout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		notifications_button_layout.setMargins(104, 130, 104, 0);
		notifications_button.setImageResource(R.drawable.notifications_button);
		dash_board_view.addView(notifications_button, notifications_button_layout);
		notifications_button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
	        	Intent notifications_intent = new Intent(DashBoard.this, Notifications.class);
	        	startActivity(notifications_intent);

				
			}
			
		});
		
		
		
		ImageView money_transfer_button = new ImageView(this);
		LinearLayout.LayoutParams money_transfer_button_layout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		money_transfer_button_layout.setMargins(104, 50, 104, 0);
		money_transfer_button.setImageResource(R.drawable.money_transfer_button);
		dash_board_view.addView(money_transfer_button, money_transfer_button_layout);
		money_transfer_button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
	        	Intent money_sender_intent = new Intent(DashBoard.this, MoneySender.class);
	        	startActivity(money_sender_intent);

				
			}
			
		});
		
		ImageView options_button = new ImageView(this);
		LinearLayout.LayoutParams options_button_layout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		options_button_layout.setMargins(104, 50, 104, 0);
		options_button.setImageResource(R.drawable.options_button);
		dash_board_view.addView(options_button, options_button_layout);
		
		ImageView reset_swipe_button = new ImageView(this);
		LinearLayout.LayoutParams reset_swipe_button_layout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		reset_swipe_button_layout.setMargins(104, 50, 104, 0);
		reset_swipe_button.setImageResource(R.drawable.reset_swipe_button);
		reset_swipe_button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
		        SharedPreferences prefs = getSharedPreferences("storage",0);
		        Editor editor = prefs.edit();
	        	editor.putBoolean("setupmode", true);
	        	editor.commit();

	        	Intent swipe_check_intent = new Intent(DashBoard.this, SwipeCheck.class);
	        	startActivity(swipe_check_intent);
			}
			
		});
		dash_board_view.addView(reset_swipe_button, reset_swipe_button_layout);	
		
		ImageView log_out_button = new ImageView(this);
		LinearLayout.LayoutParams log_out_button_layout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		log_out_button_layout.setMargins(104, 50, 104, 0);
		log_out_button.setImageResource(R.drawable.reset_app_button);
		dash_board_view.addView(log_out_button, log_out_button_layout);
		log_out_button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				
		        SharedPreferences prefs = getSharedPreferences("storage",0);
		        Editor editor = prefs.edit();
	        	editor.putBoolean("userconfigured", false);
	        	editor.commit();

	        	finish();
				
			}
			
		});
		
		setContentView(dash_board_view);
		

        
    }
}